package com.wx.registerclient.configuration;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;


/**
 * 注册中心配置类
 * yml配置文件的开始头为myconfiguration
 */
@ConfigurationProperties(prefix = "registerconfiguration")
@Component
public class NBServerConfigProperties {

    // 使用客户端扫包的路径,默认是com.wx包下面
    private String scan="com.wx";
    // 容忍连接失败的次数,默认是4次
    private Integer toleratedTimes=4;


    // 心跳时间默认是30s一次
    private Integer heartBeatTime=1000;



    // 注册中心默认端口是9527
    private String  registerPort="9527";
    // 注册中心默认地址是localhost
    private String registerHost="localhost";
    // 默认ip地址是localhost
    private String host="localhost";
    // 默认使用springCloud的项目的id
    @Value("${server.port}")
    private String port;
    // 注入服务的名字
    @Value("${spring.application.name}")
    private String serverName;
    // 是否持久化到文件中
    private boolean isStorage2File=false;
    // 如果要持久化到文件中指定文件路径
    private String filePath="d://regs";
    // 是否持久化到redis中
    private boolean isStorage2Redis=false;

    // 是否持久化到数据库中
    private boolean isStorage2Mysql=false;
    private String mysqlHost;
    private String mysqlUsername;
    private String mysqlPassword;

    @Override
    public String toString() {
        return "NBServerConfigProperties{" +
                "scan='" + scan + '\'' +
                ", toleratedTimes=" + toleratedTimes +
                ", heartBeatTime=" + heartBeatTime +
                ", registerPort='" + registerPort + '\'' +
                ", registerHost='" + registerHost + '\'' +
                ", host='" + host + '\'' +
                ", port='" + port + '\'' +
                ", serverName='" + serverName + '\'' +
                ", isStorage2File=" + isStorage2File +
                ", filePath='" + filePath + '\'' +
                ", isStorage2Redis=" + isStorage2Redis +
                ", isStorage2Mysql=" + isStorage2Mysql +
                ", mysqlHost='" + mysqlHost + '\'' +
                ", mysqlUsername='" + mysqlUsername + '\'' +
                ", mysqlPassword='" + mysqlPassword + '\'' +
                '}';
    }

    public String getScan() {
        return scan;
    }

    public void setScan(String scan) {
        this.scan = scan;
    }

    public Integer getToleratedTimes() {
        return toleratedTimes;
    }

    public void setToleratedTimes(Integer toleratedTimes) {
        this.toleratedTimes = toleratedTimes;
    }

    public Integer getHeartBeatTime() {
        return heartBeatTime;
    }

    public void setHeartBeatTime(Integer heartBeatTime) {
        this.heartBeatTime = heartBeatTime;
    }

    public String getRegisterPort() {
        return registerPort;
    }

    public void setRegisterPort(String registerPort) {
        this.registerPort = registerPort;
    }

    public String getRegisterHost() {
        return registerHost;
    }

    public void setRegisterHost(String registerHost) {
        this.registerHost = registerHost;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    public String getServerName() {
        return serverName;
    }

    public void setServerName(String serverName) {
        this.serverName = serverName;
    }

    public boolean isStorage2File() {
        return isStorage2File;
    }

    public void setStorage2File(boolean storage2File) {
        isStorage2File = storage2File;
    }

    public String getFilePath() {
        return filePath;
    }

    public void setFilePath(String filePath) {
        this.filePath = filePath;
    }

    public boolean isStorage2Redis() {
        return isStorage2Redis;
    }

    public void setStorage2Redis(boolean storage2Redis) {
        isStorage2Redis = storage2Redis;
    }

    public boolean isStorage2Mysql() {
        return isStorage2Mysql;
    }

    public void setStorage2Mysql(boolean storage2Mysql) {
        isStorage2Mysql = storage2Mysql;
    }

    public String getMysqlHost() {
        return mysqlHost;
    }

    public void setMysqlHost(String mysqlHost) {
        this.mysqlHost = mysqlHost;
    }

    public String getMysqlUsername() {
        return mysqlUsername;
    }

    public void setMysqlUsername(String mysqlUsername) {
        this.mysqlUsername = mysqlUsername;
    }

    public String getMysqlPassword() {
        return mysqlPassword;
    }

    public void setMysqlPassword(String mysqlPassword) {
        this.mysqlPassword = mysqlPassword;
    }
}
